<template>
	<div>
		<h1>欢迎你 ：{{realName}} <a @click="userOut()">退出登录</a></h1>
		<div class="homeBox">
			<div>
				<p @click="goSale()">销售</p>
				<p @click="goFindSale()">销售信息查询</p>
				<p @click="goFindStock()">查看库存</p>
			</div>
			<div class="info">
				<router-view></router-view>
			</div>
		</div>
	</div>
</template>

<script>
	import axios from 'axios'
	export default{
		data(){
			return{
				realName:sessionStorage.getItem("realName")
			}
		},
		methods:{
			goSale:function(){
				this.$router.push("/sale");
			},
			goFindSale:function(){
				this.$router.push("/findSale");
			},
			goFindStock:function(){
				this.$router.push("/findStock");
			},
			userOut:function(){
				if(confirm("是否退出？")){			
				var that=this;
				var url="http://localhost:8080/userOut";
				axios.get(url,{
					params:{
						userId:sessionStorage.getItem("id")
					}
				}).then(res=>{
						this.$router.push("/login")					
				})
			}
			}
		},
		beforeCreate() {
			this.$router.push("/welcome")
		}
	}
</script>

<style>
	.homeBox{
		display: flex;
		flex-direction: row;
	}
	.info{
		width: 600px;
		height: 250px;
		border: 1px solid black;
	}
</style>
